import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  //  {
  //   title: '供应商编号',
  //   align:"center",
  //   dataIndex: 'supplierNo'
  //  },
   {
    title: '供应商名称',
    sorter: true,
    align:"center",
    resizable: true,
    dataIndex: 'supplierName'
   },
   {
    title: '联系人',
    sorter: true,
    align:"center",
    resizable: true,
    dataIndex: 'supplierOwner'
   },
   {
    title: '电话',
    sorter: true,
    align:"center",
    resizable: true,
    dataIndex: 'mobile'
   },
   {
    title: '邮箱',
    sorter: true,
    align:"center",
    resizable: true,
    dataIndex: 'email'
   },
   {
    title: '服务开始时间',
    align: "center",
    sorter: true,
    resizable: true,
    dataIndex: 'serviceStartDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '服务结束时间',
    align: "center",
    sorter: true,
    resizable: true,
    dataIndex: 'serviceEndDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '服务状态',
    align:"center",
    sorter: true,
    resizable: true,
    dataIndex: 'serviceStatus_dictText',
    customRender: ({ text }) => {
      const color = '';
      if(text == "服务中") {
        return render.renderTag(text, "green");
      } else {
        return text;
      }
     
    }
   },
  //  {
  //   title: '社会信用代码',
  //   align:"center",
  //   dataIndex: 'socialCreditCode'
  //  },
  //  {
  //   title: '公司地址',
  //   align:"center",
  //   dataIndex: 'address'
  //  },
  //  {
  //   title: '供应商介绍',
  //   align:"center",
  //   dataIndex: 'supplierDesc'
  //  },
  //  {
  //   title: '创建人',
  //   align:"center",
  //   dataIndex: 'createBy'
  //  },
  //  {
  //   title: '创建日期',
  //   align:"center",
  //   sorter: true,
  //   dataIndex: 'createTime'
  //  },
  //  {
  //   title: '更新人',
  //   align:"center",
  //   dataIndex: 'updateBy'
  //  },
  //  {
  //   title: '更新日期',
  //   align:"center",
  //   sorter: true,
  //   dataIndex: 'updateTime'
  //  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "供应商编号",
      field: "supplierNo",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "供应商名称",
      field: "supplierName",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "社会信用代码",
      field: "socialCreditCode",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "联系人",
      field: "supplierOwner",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "电话",
      field: "mobile",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "邮箱",
      field: "email",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "创建日期",
      field: "createTime",
      component: 'DatePicker',
      componentProps: {
         showTime:true,
         valueFormat: 'YYYY-MM-DD HH:mm:ss'
       },
      //colProps: {span: 6},
 	},
	{
      label: "更新日期",
      field: "updateTime",
      component: 'DatePicker',
      componentProps: {
         showTime:true,
         valueFormat: 'YYYY-MM-DD HH:mm:ss'
       },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '供应商编号',
    field: 'supplierNo',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入供应商编号!'},
          ];
     },
  },
  {
    label: '供应商名称',
    field: 'supplierName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入供应商名称!'},
          ];
     },
  },
  {
    label: '社会信用代码',
    field: 'socialCreditCode',
    component: 'Input',
  },
  {
    label: '公司地址',
    field: 'address',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入公司地址!'},
          ];
     },
  },
  {
    label: '供应商介绍',
    field: 'supplierDesc',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const supplierContractColumns: JVxeColumn[] = [
    {
      title: '联系人',
      key: 'contract',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '职务',
      key: 'jobTitle',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '电话',
      key: 'mobile',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: false},
          { pattern: "m", message: "${title}格式不正确" }
        ],
    },
    {
      title: '邮箱',
      key: 'email',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: false},
          { pattern: "[A-Za-z0-9-._]+@[A-Za-z0-9-._]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,6})", message: "${title}格式不正确" }
        ],
    },
  ]
export const supplierPositionColumns: JVxeColumn[] = [
    {
      title: '岗位名称',
      key: 'positionName',
      type: JVxeTypes.select,
      options:[],
      dictCode:"tm_position,position_name,id",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    // {
    //   title: '岗位方向',
    //   key: 'positionDirection',
    //   type: JVxeTypes.select,
    //   options:[],
    //   dictCode:"position_direction",
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    {
      title: '岗位级别',
      key: 'positionLevel',
      type: JVxeTypes.select,
      options:[],
      dictCode:"position_level",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单价',
      key: 'positionPrice',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  supplierNo: {title: '供应商编号',order: 0,view: 'text', type: 'string',},
  supplierName: {title: '供应商名称',order: 1,view: 'text', type: 'string',},
  socialCreditCode: {title: '社会信用代码',order: 2,view: 'text', type: 'string',},
  address: {title: '公司地址',order: 6,view: 'text', type: 'string',},
  supplierDesc: {title: '供应商介绍',order: 7,view: 'textarea', type: 'string',},
  createBy: {title: '创建人',order: 8,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 9,view: 'datetime', type: 'string',},
  updateBy: {title: '更新人',order: 10,view: 'text', type: 'string',},
  updateTime: {title: '更新日期',order: 11,view: 'datetime', type: 'string',},
  //子表高级查询
  supplierContract: {
    title: '负责人',
    view: 'table',
    fields: {
        contract: {title: '联系人',order: 0,view: 'text', type: 'string',},
        jobTitle: {title: '职务',order: 1,view: 'text', type: 'string',},
        mobile: {title: '电话',order: 2,view: 'text', type: 'string',},
        email: {title: '邮箱',order: 3,view: 'text', type: 'string',},
    }
  },
  supplierPosition: {
    title: '岗位列表',
    view: 'table',
    fields: {
        positionName: {title: '岗位名称',order: 0,view: 'list', type: 'string',dictTable: "tm_position", dictCode: 'id', dictText: 'position_name',},
        // positionDirection: {title: '岗位方向',order: 1,view: 'list', type: 'string',dictCode: 'position_direction',},
        positionLevel: {title: '岗位级别',order: 2,view: 'list', type: 'string',dictCode: 'position_level',},
        positionPrice: {title: '单价',order: 3,view: 'number', type: 'number',},
    }
  },
};
